function success(text){
	  $("#alerts").html("<div  style='text-align: center; display:no;' class='alert alert-success alert-dismissable'><strong>"+text+"</strong></div>");
	  $("#menus").click();

}
//操作失败之后提示
function fail(text){
	  $("#alerts").html("<div  style='text-align: center; display:no;' class='alert alert-success alert-dismissable'><strong>"+text+"</strong></div>");
	  $("#menus").click();
}
function myfresh(){
	window.location.href=window.location.href;
}
//得到app的详细信息
function toAppDetail(appId){
	$.post("../app/getAppDeatilById.do",
			{appId:appId},
		function(data){
			$("#appId").val(appId);
			$("#appName").val(data.appName);
			$("#textAboutMe").val(data.aboutMe);
			$("#textVersionIntroduce").val(data.versionIntroduce);
		},
		'json'
	);
}
//得到所有反馈的信息
function toProblem(appId){
	$("#ProblemDivlist>table>tbody").empty();
	$.post(
		"../app/getProblemByAppId.do",
		{appId:appId},
		function(data){
			$.each(data,function(i,problem){
				$("#ProblemDivlist>table>tbody").append(makeModelOfProblem(problem));
			});
		},
		'json'
	);
	
}
//反馈的model中表格生成
function makeModelOfProblem(problem){
	var tr=$('<tr class="gradeA even"></tr>');
	tr.append('<td class="" >'+problem.problemCount+'</td>');
	tr.append('<td class="" >'+problem.problemTime+'</td>');
	return tr;
}
//app基本信息,修改保存
function updateAppData(){
	$.post(
			"../app/updateAppData.do",
			$("#appDetailFrom").serialize(),
			function(data){
				if(data==0){
					//修改成功
					success("信息修改成功了!");
					setTimeout(myfresh,1000);
				}else if(data==1){
					//未修改数据
					success("为什么不修改数据,就点我呢?");
					setTimeout(myfresh,1000);
				}else{
					//修改失败
					fail("恭喜你修改失败了!");
					setTimeout(myfresh,1000);
				}
			},
			'json'
	);
}
//新增app
function addApp(){
	$.post(
			"../app/addNewApp.do",
			$("#addAppDetailFrom").serialize(),
			function(data){
				if(data==0){
					//修改成功
					success("新增app成功了!");
					setTimeout(myfresh,1000);
				}else if(data==1){
					//未修改数据
					success("该app所有的信息没有填, 增加了 一个空的app");
					setTimeout(myfresh,1000);
				}else{
					//修改失败
					fail("恭喜你新增失败了!");
					setTimeout(myfresh,1000);
				}
			},
			'json'
	);	
}
//广告图片
function showImgs(imgs){
	$("#adverPictureModel>div>div>div[class='modal-body']").empty();
	for(var i=0;i<imgs.length;i++){
		$("#adverPictureModel>div>div>div[class='modal-body']").append("<h3>广告图片"+(i+1)+"</h3>");
		$("#adverPictureModel>div>div>div[class='modal-body']").append('<img alt="" src="http://oeilufnx2.bkt.clouddn.com/'+imgs[i]+'?imageView2/1/w/800/h/800">');
	}
	
}
//广告图片的点击事件
function adverPictureTd(adverId){
	$("#adverPictureModel>div>div>div[class='modal-body']").empty();
	$.post("../app/getPictureByAdverId.do",
		{adverId:adverId},
		function(data){
			$.each(data,function(i,ad){
				$("#adverPictureModel>div>div>div[class='modal-body']").append("<h3>广告图片"+(i+1)+"</h3>");
				$("#adverPictureModel>div>div>div[class='modal-body']").append('<img alt="" src="http://oeilufnx2.bkt.clouddn.com/'+ad.img+'?imageView2/1/w/800/h/800">');
			});
		},
		'json'
	);
}
//修改启动广告的状态
function updateAdverSwitch(adverId,adverStatus){
	if(adverStatus==1){
		//那么就往后台传0
		$.post("../app/updateAdverStatus.do",
			{
			adverId:adverId,
			adverStatus:0
				},
			function(data){
					if(data==0){
						success("广告状态关闭成功!!");
						setTimeout(myfresh,2000);
					}			
			},
			'json'
		);
	}else if(adverStatus==0){
		//那么就往后台传1
		$.post("../app/updateAdverStatus.do",
				{
				adverId:adverId,
				adverStatus:1
					},
				function(data){
						if(data==0){
							success("广告状态开启成功!!");
							setTimeout(myfresh,2000);

						}
				},
				'json'
			);
		
	}
}
//跳到修改图片
function toUpdateAdverPircture(adverId){
	$("#adverIdInput").val(adverId);
}
//调用单独上传图片的接口
function uploadImgs(){
	
}


//修改广告的图片
function saveNewAdPicture(){
	$("#inputForm").submit();
}








